package leetcode.bits;

/**
 * @Description: https://leetcode.cn/problems/is-unique-lcci/description/
 * @Author Ammar
 * @Create 2023/9/9 16:35
 */
public class _面试题01_判定字符是否唯一 {
    public boolean isUnique(String astr) {
        long bits = 0;
        int size = astr.length();
        for (int i = 0; i < size; i++) {
            int move = astr.charAt(i) - 'a';
            if ((bits & (1L << move)) != 0) {
                return false;
            } else {
                bits = bits | (1L << move);
            }
        }
        return true;
    }
}
